﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace DualityEngine.Business.GameModel
{
    public class Skybox : GameModel
    {
        public Skybox(Vector3 position, Model model)
            : base(position, model)
        {
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(CameraManager.Instance.ActiveCamera.cameraposition);
                    effect.View = CameraManager.Instance.ActiveCamera.viewmatrix;
                    effect.Projection = CameraManager.Instance.ActiveCamera.projectionmatrix;
                }
                mesh.Draw();
            }
        }
    }
}
